package com.zkca.xf.presenter;

import android.util.Log;

import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import com.zkca.xf.ConstantsXF;
import com.zkca.xf.base.BasePresenter;
import com.zkca.xf.manager.DataManager;
import com.zkca.xf.model.javabean.ServerSelectBean;
import com.zkca.xf.model.javabean.UserId;
import com.zkca.xf.net.ApiManager;
import com.zkca.xf.net.RetrofitHelper;
import com.zkca.xf.utils.LogUtil;
import com.zkca.xf.view.LoginView;
import com.zkca.xf.view.SelectServerView;

import java.io.IOException;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.observers.DefaultObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
//import retrofit2.converter.simplexml.SimpleXmlConverterFactory;

/**
 * Created by li on 2018/7/31.
 */

public class SelectServerPresenter extends BasePresenter {


    private DataManager dataManager;
    private SelectServerView selectServerView;
    private Retrofit retrofit;

    public SelectServerPresenter(LifecycleProvider<ActivityEvent> provider, SelectServerView selectServerView) {
        super(provider);
        this.selectServerView = selectServerView;
        dataManager = DataManager.getInstance();

    }


    //获取服务器信息
    public void SelectServer() {
        OkHttpUtils.get().url(ConstantsXF.SELECT_SERVER).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int i) {
                Log.e("<>","0000000"+e);
            }

            @Override
            public void onResponse(String s, int i) {
                selectServerView.getSelectServer(s);
            }
        });

    }
}
